import React, { Component } from "react";
import ReactDOM from 'react-dom';
import {store} from "../help/global.js";
import * as actions from "../actions/index.js"

export default class Todo extends Component {
    constructor(props){
        super(props)
        const { data, index }=this.props;        
    }

    todoClick(index){
        store.dispatch(actions.completeTodo(index))
    }

    render() {
        const { data, index }=this.props;
        return (
            <li style={{textDecoration
            :data.completed?"line-through":"none"}} onClick={e=>{this.todoClick(index)}}>
                {data.text}
            </li>
        )
    }
}